import departmentApi from '@/network/map/department.api'
const state = {
  hospitals: [],
  tree: [
    {label: '全部', children: []}
  ]
}

const mutations = {
  SAVE_HOSPITALS(sate,data) {
    state.tree[0].children = data
    sate.hospitals = data.map(item => { return {locationId: item.keyword,name: item.label}})
  }
}

const actions = {
  async saveHospitals({commit}) {
    const data = await departmentApi.getMenuTree()
    commit('SAVE_HOSPITALS',data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
